package com.wzh.controll;

import com.wzh.pojo.Po.Cash;
import com.wzh.pojo.Po.User;
import com.wzh.pojo.Req.DataReq;
import com.wzh.pojo.Resp.DataResp;
import com.wzh.pojo.result;
import com.wzh.service.Userser;
import com.wzh.util.CommmonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/Money")
public class MoneyController {
	@Autowired
	private Userser userser;



	//添加金额
	@PostMapping("/addCoin")
	@ResponseBody
	public result addCoin(@RequestBody User user) {

		if (!CommmonUtil.deParma(user.getParma())){
			return new result("参数有误！",204);
		}
		//boolean res = userser.addMoney(user);
		boolean res = userser.addUserRecord(user);
		String mes=res!=false?"操作成功":"操作失败";
		Integer code=res!=false?200:300;
		return new result(mes,code);
	}



	//减少金额
	@PostMapping("/delCoin")
	@ResponseBody
	public result delCoin(@RequestBody User user2) {

		boolean res = userser.delCoin(user2);
		String mes=res!=false?"操作成功":"操作失败";
		Integer code=res!=false?200:300;
		return new result(mes,code);
	}

	//查看所有用户提现记录
	@PostMapping("/getCashRecord")
	@ResponseBody
	public DataResp getCashRecord(@RequestBody DataReq req){
		DataResp<Object> resp= userser.getCashRecord(req);
		return resp;
	};

	//用户提现
	@PostMapping("/sendCashRecord")
	@ResponseBody
	public DataResp sendCashRecord(@RequestBody Cash cash) {
		DataResp<Object> resp= userser.sendCashRecord(cash);
		return resp;
	}

	//用户提现审核
	@PostMapping("/checkCashRecord")
	@ResponseBody
	public DataResp checkCashRecord(@RequestBody  Cash cash) {
		DataResp<Object> resp= userser.checkCashRecord(cash);
		return resp;
	}

	//查看单个用户上传收益记录 风控管理
	@PostMapping("/getMoneyRecord")
	@ResponseBody
	public DataResp getMoneyRecord(@RequestBody DataReq req){
		DataResp<Object> resp= userser.getMoneyRecord(req);
		return resp;
	};


}
